/**
 * Licensee: DuKe TeAm
 * License Type: Purchased
 */
package ormsamples;

import org.orm.*;
public class ListPrueba1PDSData {
	private static final int ROW_COUNT = 100;
	
public void listTestData() throws PersistentException {
		orm.DAOFactory lDAOFactory = orm.DAOFactory.getDAOFactory();
		System.out.println("Listing Atencion...");
		orm.Atencion[] oRMAtencions = lDAOFactory.getAtencionDAO().listAtencionByQuery(null, null);
		int length = Math.min(oRMAtencions.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(oRMAtencions[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing Prestacion...");
		orm.Prestacion[] oRMPrestacions = lDAOFactory.getPrestacionDAO().listPrestacionByQuery(null, null);
		length = Math.min(oRMPrestacions.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(oRMPrestacions[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing Paciente...");
		orm.Paciente[] oRMPacientes = lDAOFactory.getPacienteDAO().listPacienteByQuery(null, null);
		length = Math.min(oRMPacientes.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(oRMPacientes[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
	}
	
	public void listByCriteria() throws PersistentException  {
		System.out.println("Listing Atencion by Criteria...");
		orm.AtencionCriteria atencionCriteria = new orm.AtencionCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//atencionCriteria.idAtencion.eq();
		atencionCriteria.setMaxResults(ROW_COUNT);
		orm.Atencion[] oRMAtencions = atencionCriteria.listAtencion();
		int length =oRMAtencions== null ? 0 : Math.min(oRMAtencions.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(oRMAtencions[i]);
		}
		System.out.println(length + " Atencion record(s) retrieved."); 
		
		System.out.println("Listing Prestacion by Criteria...");
		orm.PrestacionCriteria prestacionCriteria = new orm.PrestacionCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//prestacionCriteria.idPrestacion.eq();
		prestacionCriteria.setMaxResults(ROW_COUNT);
		orm.Prestacion[] oRMPrestacions = prestacionCriteria.listPrestacion();
		length =oRMPrestacions== null ? 0 : Math.min(oRMPrestacions.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(oRMPrestacions[i]);
		}
		System.out.println(length + " Prestacion record(s) retrieved."); 
		
		System.out.println("Listing Paciente by Criteria...");
		orm.PacienteCriteria pacienteCriteria = new orm.PacienteCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//pacienteCriteria.idPaciente.eq();
		pacienteCriteria.setMaxResults(ROW_COUNT);
		orm.Paciente[] oRMPacientes = pacienteCriteria.listPaciente();
		length =oRMPacientes== null ? 0 : Math.min(oRMPacientes.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(oRMPacientes[i]);
		}
		System.out.println(length + " Paciente record(s) retrieved."); 
		
	}
	
	public static void main(String[] args) {
		try {
			ListPrueba1PDSData listPrueba1PDSData = new ListPrueba1PDSData();
			try {
				listPrueba1PDSData.listTestData();
				//listPrueba1PDSData.listByCriteria();
			}
			finally {
				orm.Prueba1PDSPersistentManager.instance().disposePersistentManager();
			}
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
